package com.sls.nzdapplication.ui.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;

import com.esri.arcgisruntime.geometry.Geometry;
import com.esri.arcgisruntime.geometry.Point;
import com.esri.arcgisruntime.geometry.SpatialReference;
import com.esri.arcgisruntime.geometry.SpatialReferences;
import com.esri.arcgisruntime.layers.WebTiledLayer;
import com.esri.arcgisruntime.mapping.ArcGISMap;
import com.esri.arcgisruntime.mapping.Basemap;
import com.esri.arcgisruntime.mapping.Viewpoint;
import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener;
import com.esri.arcgisruntime.mapping.view.Graphic;
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay;
import com.esri.arcgisruntime.mapping.view.MapView;
import com.esri.arcgisruntime.symbology.PictureMarkerSymbol;
import com.esri.arcgisruntime.symbology.SimpleMarkerSymbol;
import com.esri.arcgisruntime.symbology.SimpleRenderer;
import com.sls.nzdapplication.R;
import com.sls.nzdapplication.tiandimap.TianDiTuMethodsClass;
import com.sls.nzdapplication.util.Utils;

public class MainActivity extends AppCompatActivity {

    private GraphicsOverlay graphicsOverlay;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        MapView mMapView = findViewById(R.id.map_view);
        WebTiledLayer webTiledLayer2 = TianDiTuMethodsClass.CreateTianDiTuTiledLayer(TianDiTuMethodsClass.LayerType.TIANDITU_IMAGE_2000);
        Basemap tdtBasemap2 = new Basemap(webTiledLayer2);
        WebTiledLayer webTiledLayer22 = TianDiTuMethodsClass.CreateTianDiTuTiledLayer(TianDiTuMethodsClass.LayerType.TIANDITU_IMAGE_ANNOTATION_CHINESE_2000);
        tdtBasemap2.getBaseLayers().add(webTiledLayer22);

        ArcGISMap map = new ArcGISMap(tdtBasemap2);
        mMapView.setMap(map);
        mMapView.setViewpoint(new Viewpoint(34.77669, 113.67922, 10000));
        graphicsOverlay = new GraphicsOverlay(GraphicsOverlay.RenderingMode.STATIC);
        mMapView.getGraphicsOverlays().add(graphicsOverlay);
        PictureMarkerSymbol simpleMarkerSymbol= new PictureMarkerSymbol(new BitmapDrawable(Utils.getMardBitmap("测试2124124141",R.drawable.tower_new,getApplicationContext())));
       
        Graphic graphic = new Graphic(new Point(113.67922,34.77669),simpleMarkerSymbol);
        simpleMarkerSymbol.loadAsync();
        simpleMarkerSymbol.addDoneLoadingListener(new Runnable() {
            @Override
            public void run() {
                graphicsOverlay.getGraphics().clear();
                graphicsOverlay.getGraphics().add(graphic);
            }
        });

    }
}